package best.driver.android.View.photocrop;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import best.driver.android.R;


public class MyDetailSelectItemView extends LinearLayout {

    private String mLeftString;
    private String mRightString;

    private int titleResource;

    private TextView mLeftText;
    private TextView mRightText;

    private int mLeftId;
    private int mRightId;

    public MyDetailSelectItemView(Context context) {
        this(context, null);
    }

    public MyDetailSelectItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.my_detail_select_item, this, true);
        mLeftText = (TextView) findViewById(R.id.tv_left);
        mRightText = (TextView) findViewById(R.id.tv_right);
        if (attrs != null) {
            initWithAttributes(context, attrs);
        }
    }

    public void setStringResource(String leftString, String rightString, String hint) {
        mLeftString = leftString;
        mLeftText.setText(leftString);
        if(!TextUtils.isEmpty(rightString)) {
            mRightString = rightString;
            mRightText.setText(rightString);
        }
        mRightText.setHint(hint);
    }

    public void setContent(String content) {
        if(!TextUtils.isEmpty(content))
        mRightText.setText(content);
    }

    private void initWithAttributes(Context context, AttributeSet attrs) {
        titleResource = attrs.getAttributeResourceValue(null, "title", 0);
        String title = "";
        if (titleResource != 0) {
            title = context.getString(titleResource);
        } else {
            title = attrs.getAttributeValue(null, "title");
        }
        mLeftText.setText(title);

    }

    public String getLeftString() {
        return mLeftText.getText().toString();
    }

    public String getRightString() {
        return mRightText.getText().toString();
    }

    public TextView getRightText() {
        return mRightText;
    }

    public void showNext() {
        findViewById(R.id.iv_next).setVisibility(View.VISIBLE);
    }



}
